from apps.goods.models import SPU,Brand,GoodsCategory
from rest_framework.serializers import ModelSerializer
from rest_framework import serializers


class SPUModelSerializer(ModelSerializer):
    """SPU管理序列化器"""
    brand_id=serializers.IntegerField()
    brand = serializers.StringRelatedField()

    category1_id=serializers.IntegerField()
    category2_id=serializers.IntegerField()
    category3_id=serializers.IntegerField()

    category1 = serializers.StringRelatedField()
    category2 = serializers.StringRelatedField()
    category3 = serializers.StringRelatedField()

    class Meta:
        model=SPU
        fields = '__all__'

class BrandModelSerializer(ModelSerializer):
    """获取品牌名称序列化器"""

    class Meta:
        model=Brand
        fields=('name','id')

class GoodsCategoryModelSerializer(ModelSerializer):
    """获得分类序列化器"""

    class Meta:
        model = GoodsCategory
        fields=('id','name')
